<?php
include_once 'include.php';
$total = sql_count('lyy_message','id','pid=0');#总行数
$curr = isset($_REQUEST['curr'])?$_REQUEST['curr']:1;#当前页
$limit = 10;#每页多少行
$page = ceil($total/$limit);#总共有多少页
$offset = ($curr-1)*$limit;
$sql = "select a.id,a.content,a.createtime,b.username,b.email from lyy_message a 
JOIN lyy_member b ON a.uid=b.id where pid =0 limit $offset,$limit";
$res = mysqli_query(conn(),$sql);
$lists = mysqli_fetch_all($res,MYSQLI_ASSOC);#留言列表
?>
<!DOCTYPE html>
<html>
<head>
    <?php include_once 'common_js_css.php'?>
	<link rel="stylesheet" type="text/css" href="css/kejian.css">
</head>
<body marginheight="0">
    <div class="cont" style="height: 910px">
        <div class="flash">
            <span><h1>留言板</h1></span>
        </div>
        <hr style="height:1px;border:none;border-top:2px solid blue;" />
        <form name="form2" method="post" action="">
            <table width="990" class="ta"  style="border-collapse:separate; border-spacing:0px 0px;">

                <tr class="tr1">
                    <td width="50" align="center" valign="middle">序号</td>
                    <td width="80" align="center" valign="middle">用户账号</td>
                    <td width="300" align="center">留言内容</td>
                    <td width="180" align="center">留言时间</td>
                    <td width="80" align="center">
                        <div class="container"> <a href="javascript:;" style="line-height: 50px;">我要留言</a> </div>
                    </td>
                </tr>

                <tbody id="ppt">
                <?php foreach ($lists as $list): ?>
                    <tr>
                        <td align="center" valign="middle" height="40"><?php echo $list['id']; ?></td>
                        <td align="center"><?php echo $list['username']; ?></td>
                        <td align="center"><?php echo $list['content']; ?></td>
                        <td align="center"><?php echo date('Y-m-d H:i:s',$list['createtime']); ?></td>
                        <td align="center"><p><a href="reply.php?id=<?php echo $list['id']; ?>" target="mainFrame">回复</a></p></td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
                <tr><td></td></tr>
                <tfoot>
                <!--显示分页，只有一页，即不显示分页-->
                <tr><td colspan="6" height="60"><b><?php if($total>$limit){echo showPage($curr,$page);}?></b></td></tr>
                </tfoot>
            </table>
        </form>
    </div>

    <div class="fulled">
        <div class="fix-box">
            <p class="close">关闭</p>
            <span>我要留言</span>
            <table>
                <tr>
                    <td>内容:</td>
                    <td><textarea rows="10" cols="30" id="content"></textarea></td>
                </tr>
                <tr>
                    <td colspan="2" align="center"><input type="button" value="提交" onclick="add_reply(0)"></td>
                </tr>
            </table>
        </div>
    </div>
</body>
</html>